<template>

	<view class="page-user">
		<view class="user-info">
			<u-avatar :src="userInfo.headimgurl" size="80" @click="gotoDirector()"></u-avatar>
			<view class="user-nickname u-line-1" @click="gotoDirector()">
				<text class="u-line-1">{{userInfo.nickname }}</text>
			</view>
		</view>
 

	
	
	
<view class="list">
	<view class="btn order" @click="goto_order()" >全部订单</view>
	<view class="btn aftersale" @click="goto_order()" >售后订单</view>
	<view class="btn student" @click="goto_student()">学生名单</view>
</view>


    <!-- 联系我们部分 -->
    <view class="contact-us">
      <view class="section-title">联系我们</view>
	  
      <view class="contact-item" v-for="(employee ,index) in employee_list" :key="index" @tap="make_call(employee.phone)">
        <image src="/static/imgs/teacher.png" class="contact-icon"></image>
        <view class="contact-name">{{employee.name}}</view>
        <text class="contact-phone">电话：{{employee.phone}}</text>
      </view>
	  
    </view>
 
	</view>
</template>

<script>
	import * as UserApi from '@/api/user'
	import * as MemberApi from '@/api/member.js'
	import * as employee_api from '@/api/employee.js'
	export default {

		data() {
			return {
				officialShow: false,
				isLogin: false,
				employee_list:{},
				userInfo: {
					headimgurl: "https://youqu.arrow.enpingshi.com/uploadfiles/logo.jpg",
					nickname: "请点击登录",
					event_number: 0
				},

				numberList: [
					{
						number: 0,
						title: '我的订单',
						url: '/pages/myactivity/myactivity'
					},
					{
						number: 0,
						title: '用户信息',
						url: '/pages/user/set'
					},
					
					 
				],

			 

				baseList: [
		 
					{
						name: '/static/icon/settings.png',
						title: '个人资料',
						url: '/pages/user/set'
					},
					{
						name: '/static/icon/grouptag.png',
						title: '团体',
						url: '/pages/user/mygroup'
					},
					{
						name: '/static/icon/message.png',
						title: '消息设置',
						url: '/pages/message/message'
					},
					{
						name: '/static/icon/refund.png',
						title: '退款/评价',
						url: '/pages/myactivity/myactivity'
					},
				]
			}
		},
		onLoad() {
			// 获取当前用户信息

		},
		onShow() {
			if (uni.getStorageSync('user_id')) {
				this.isLogin = true

				this.getUserInfo()

			}
			else if (!this.isLogin) {
				uni.navigateTo({
					url: "/pages/login/index"
				})
			} 
 
			this.get_employee_list();
		},
		methods: {
			
	 
			
			goto_order() {
					uni.switchTab({
						url: "/pages/myactivity/myactivity"
					})
			},
			
			goto_student() {
					uni.navigateTo({
						url: "/pages/user/student_list"
					})
			},
			make_call(phone) {
				uni.makePhoneCall({
					phoneNumber: phone
				})
			},
			 

 get_employee_list()
 {
	
	employee_api.employee_list().then(res => {
		this.employee_list = res.data
		console.log("this.employee_list",this.employee_list)
	})
	 
 },

			gotoPage(url) {
				if (!this.isLogin) {
					uni.navigateTo({
						url: "/pages/login/index"
					})
				} else {
					uni.navigateTo({
						url: url
					})
				}
			},

 
			// 获取当前用户信息
			getUserInfo() {
				UserApi.userInfo().then(res => {

					this.userInfo = res.info
					//会根据页面按钮情况去判断是否增加局长申请这个按钮。数字对不上的话，就会不断的加
					if (this.userInfo.leader != '是' && this.baseList.length <= 4) {
					//if (this.userInfo.leader != '是' ) {
						this.baseList.push({
							name: '/static/icon/apply.png',
							title: '局长申请',
							url: '/pages/director/director'
						})
					}
					this.numberList[0].number = this.userInfo.event_number
					this.numberList[1].number = this.userInfo.interest_number
					this.numberList[2].number = this.userInfo.being_interest_number
					this.numberList[3].number = this.userInfo.sms_free_number
					this.numberList[4].number = this.userInfo.sms_charged_number

				})
			},

		}
	}
</script>



<style scoped lang="scss">
	@import url("asset/style.css");
</style>

 